Micron Document
πŸŽ–οΈGitΠ―Ρ€Π°πŸŽ–οΈ


Displaying Raw β€’ Download

core/takserver/src/commonMain/kotlin/org/meshtastic/core/takserver/TAKDefaults.kt b4bedd92fcc8d65daff79200d71f6ebc3d8f0cfa (b4bedd92) Text, 6.88 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.takserver

Tff7b72import T7ee787org.meshtastic.proto.MemberRole
Tff7b72import T7ee787org.meshtastic.proto.Team
Tff7b72import T7ee787org.meshtastic.proto.User

T8b949e// Port 8089 is the standard TAK TLS port. Matches the iOS implementation so that
T8b949e// a single exported data package (containing truststore.p12 + client.p12) works for
T8b949e// both Meshtastic-iOS and Meshtastic-Android without reconfiguration in ATAK/iTAK.
Tff7b72internal Tff7b72const Tff7b72val Te6edf3DEFAULT_TAK_PORT Tff7b72= T79c0ff8T79c0ff0T79c0ff8T79c0ff9

T8b949e// Default contact endpoint for mesh peers (the real endpoint is never carried over
T8b949e// LoRa). MUST be the TAK "reply via this server" form `*:-1:stcp`: it makes ATAK route
T8b949e// directed GeoChat / TAK-Talk (`<marti>`) back down the Meshtastic server stream. A
T8b949e// concrete host (e.g. `0.0.0.0:4242:tcp`) makes ATAK attempt a dead direct connection,
T8b949e// so directed messages never reach the mesh while broadcast PLI still works.
Tff7b72internal Tff7b72const Tff7b72val Te6edf3DEFAULT_TAK_ENDPOINT Tff7b72= Ta5d6ff"Ta5d6ff*:-1:stcpTa5d6ff"

T8b949e// Bundled certificate password β€” matches iOS (`"meshtastic"`). Used for the
T8b949e// server.p12 / client.p12 PKCS#12 files shipped under `tak_certs/` on the classpath.
Tff7b72internal Tff7b72const Tff7b72val Te6edf3TAK_BUNDLED_CERT_PASSWORD Tff7b72= Ta5d6ff"Ta5d6ffmeshtasticTa5d6ff"
Tff7b72internal Tff7b72const Tff7b72val Te6edf3DEFAULT_TAK_TEAM_NAME Tff7b72= Ta5d6ff"Ta5d6ffCyanTa5d6ff"
Tff7b72internal Tff7b72const Tff7b72val Te6edf3DEFAULT_TAK_ROLE_NAME Tff7b72= Ta5d6ff"Ta5d6ffTeam MemberTa5d6ff"
Tff7b72internal Tff7b72const Tff7b72val Te6edf3DEFAULT_TAK_BATTERY Tff7b72= T79c0ff1T79c0ff0T79c0ff0
Tff7b72internal Tff7b72const Tff7b72val Te6edf3DEFAULT_TAK_STALE_MINUTES Tff7b72= T79c0ff1T79c0ff0
Tff7b72internal Tff7b72const Tff7b72val Te6edf3TAK_HEX_RADIX Tff7b72= T79c0ff1T79c0ff6
Tff7b72internal Tff7b72const Tff7b72val Te6edf3TAK_XML_READ_BUFFER_SIZE Tff7b72= T79c0ff4Te6edf3_096

T8b949e// ATAK's native commo library declares the connection dead after 25 seconds of
T8b949e// silence (RX_TIMEOUT_SECONDS in streamingsocketmanagement.cpp) and starts
T8b949e// sending t-x-c-t pings at 15 seconds (RX_STALE_SECONDS). Send keepalives
T8b949e// well under the 15-second threshold so ATAK never enters its stale phase.
Tff7b72internal Tff7b72const Tff7b72val Te6edf3TAK_KEEPALIVE_INTERVAL_MS Tff7b72= T79c0ff1T79c0ff0Te6edf3_000L
Tff7b72internal Tff7b72const Tff7b72val Te6edf3TAK_ACCEPT_LOOP_DELAY_MS Tff7b72= T79c0ff1T79c0ff0T79c0ff0L
Tff7b72internal Tff7b72const Tff7b72val Te6edf3TAK_COORDINATE_SCALE Tff7b72= T79c0ff1Te6edf3e7
Tff7b72internal Tff7b72const Tff7b72val Te6edf3TAK_UNKNOWN_POINT_VALUE Tff7b72= T79c0ff9Te6edf3_999_999Tb4b4b4.T79c0ff0
Tff7b72internal Tff7b72const Tff7b72val Te6edf3TAK_DIRECT_MESSAGE_PARTS_MIN Tff7b72= T79c0ff3

T8b949e/**
* Hard cap on the size of a TAK v2 wire payload we will hand to the mesh layer.
*
* `CommandSenderImpl.sendData` checks `Data.ADAPTER.isWithinSizeLimit(data, Constants.DATA_PAYLOAD_LEN.value)` where
* `DATA_PAYLOAD_LEN = 233`. That 233 applies to the ENTIRE encoded `Data` proto (portnum tag + payload length-delim +
* reply_id + emoji), not just the `payload` bytes. The wrapper for a port-78 (`ATAK_PLUGIN_V2`) message costs roughly:
* * portnum varint + tag: 2 bytes
* * payload length prefix + tag: 2–3 bytes (depending on size)
* * reply_id / emoji: 0 bytes when unset
*
* That leaves ~228 bytes for the `payload` field alone. We use 225 to keep a small margin for future proto evolution.
* Anything larger than this is dropped in [TAKMeshIntegration.sendCoTToMesh] rather than being handed to the mesh
* layer, because the mesh layer would throw and the outer `SharedFlow` collector would eat the crash on every
* subsequent emission.
*/
Tff7b72internal Tff7b72const Tff7b72val Te6edf3MAX_TAK_WIRE_PAYLOAD_BYTES Tff7b72= T79c0ff2T79c0ff2T79c0ff5

T8b949e/** Default CoT type for PLI (Position Location Information) β€” friendly ground unit. */
Tff7b72internal Tff7b72const Tff7b72val Te6edf3DEFAULT_PLI_COT_TYPE Tff7b72= Ta5d6ff"Ta5d6ffa-f-G-U-CTa5d6ff"

T8b949e// ── Mesh-to-CoT (synthesized node contacts) ─────────────────────────────────
T8b949e// These values mirror Meshtastic-Apple's TAKMeshtasticBridge.createCoTFromNode so a
T8b949e// mesh node presents identically in ATAK whether the operator runs Android or iOS.
T8b949e// Changing any of them makes the same physical node appear as a different contact
T8b949e// depending on which phone is bridging.

T8b949e/**
* UID prefix for synthesized node CoT, e.g. `MESHTASTIC-A1B2C3D4`.
*
* The hex suffix is **upper-case, zero-padded to [MESH_NODE_UID_HEX_WIDTH]**, matching Apple's `String(format:
* "MESHTASTIC-%08X", node.num)`. ATAK keys a contact by UID and compares case-sensitively, so lower-casing this makes
* an Android-bridged node a *different* contact from the same iOS-bridged node β€” the mesh appears duplicated whenever
* both phones bridge into one TAK network.
*/
Tff7b72internal Tff7b72const Tff7b72val Te6edf3MESH_NODE_UID_PREFIX Tff7b72= Ta5d6ff"Ta5d6ffMESHTASTIC-Ta5d6ff"

T8b949e/** Hex digits in a node number, zero-padded β€” `%08X` on the Apple side. */
Tff7b72internal Tff7b72const Tff7b72val Te6edf3MESH_NODE_UID_HEX_WIDTH Tff7b72= T79c0ff8

T8b949e/** Team colour for synthesized node CoT. Remote nodes never report a TAK team, so Apple's fixed Green is used. */
Tff7b72internal Tff7b72const Tff7b72val Te6edf3MESH_NODE_TAK_TEAM Tff7b72= Ta5d6ff"Ta5d6ffGreenTa5d6ff"

T8b949e/**
* Stale TTL for synthesized node CoT. Longer than [DEFAULT_TAK_STALE_MINUTES] because a mesh node's position updates
* far less often than a live TAK client's. [MESH_TO_COT_REFRESH_INTERVAL_MS] must stay comfortably below this or
* stationary nodes expire out of ATAK between refreshes.
*/
Tff7b72internal Tff7b72const Tff7b72val Te6edf3MESH_NODE_STALE_MINUTES Tff7b72= T79c0ff1T79c0ff5

T8b949e/**
* How often every eligible node is re-broadcast even when nothing about it changed. Keeps stationary nodes alive in
* ATAK, whose markers would otherwise expire at [MESH_NODE_STALE_MINUTES].
*/
Tff7b72internal Tff7b72const Tff7b72val Te6edf3MESH_TO_COT_REFRESH_INTERVAL_MS Tff7b72= T79c0ff5L Tff7b72* T79c0ff6T79c0ff0L Tff7b72* T79c0ff1Te6edf3_000L

T8b949e/** Spacing between consecutive node broadcasts so a full replay doesn't flood the TAK client. Matches Apple's 10ms. */
Tff7b72internal Tff7b72const Tff7b72val Te6edf3MESH_TO_COT_BROADCAST_SPACING_MS Tff7b72= T79c0ff1T79c0ff0L

T8b949e/**
* Max characters of raw CoT XML we'll write to logcat when dropping an oversized packet. ATAK can emit events several
* KB long; logging the whole thing floods logcat and buries the signal. 1024 chars is enough to see the event type,
* point, and the first few detail elements.
*/
Tff7b72internal Tff7b72const Tff7b72val Te6edf3TAK_LOG_XML_MAX_CHARS Tff7b72= T79c0ff1Te6edf3_024

Tff7b72internal Tff7b72fun Td2a8ffTeamTff7b72?.Te6edf3toTakTeamNameTb4b4b4(Tb4b4b4)Tb4b4b4: Tffa657String Tff7b72= Tff7b72when Tb4b4b4(Tff7b72thisTb4b4b4) Tb4b4b4{
Tff7b72nullTb4b4b4,
Te6edf3TeamTb4b4b4.Te6edf3Unspecifed_ColorTb4b4b4,
Tff7b72-Tff7b72> Te6edf3DEFAULT_TAK_TEAM_NAME

Tff7b72else Tff7b72-Tff7b72> Te6edf3nameTb4b4b4.Te6edf3replaceTb4b4b4(Ta5d6ff'_'Tb4b4b4, Ta5d6ff' 'Tb4b4b4)
Tb4b4b4}

Tff7b72internal Tff7b72fun Td2a8ffMemberRoleTff7b72?.Te6edf3toTakRoleNameTb4b4b4(Tb4b4b4)Tb4b4b4: Tffa657String Tff7b72= Tff7b72when Tb4b4b4(Tff7b72thisTb4b4b4) Tb4b4b4{
Tff7b72nullTb4b4b4,
Te6edf3MemberRoleTb4b4b4.Te6edf3UnspecifedTb4b4b4,
Tff7b72-Tff7b72> Te6edf3DEFAULT_TAK_ROLE_NAME

Te6edf3MemberRoleTb4b4b4.Te6edf3TeamMember Tff7b72-Tff7b72> Te6edf3DEFAULT_TAK_ROLE_NAME

Te6edf3MemberRoleTb4b4b4.Te6edf3TeamLead Tff7b72-Tff7b72> Ta5d6ff"Ta5d6ffTeam LeadTa5d6ff"

Te6edf3MemberRoleTb4b4b4.Te6edf3ForwardObserver Tff7b72-Tff7b72> Ta5d6ff"Ta5d6ffForward ObserverTa5d6ff"

Tff7b72else Tff7b72-Tff7b72> Te6edf3name
Tb4b4b4}

Tff7b72internal Tff7b72fun Te6edf3UserTb4b4b4.Td2a8fftoTakCallsignTb4b4b4(Tb4b4b4)Tb4b4b4: Tffa657String Tff7b72= Tff7b72when Tb4b4b4{
Te6edf3short_nameTb4b4b4.Te6edf3isNotBlankTb4b4b4(Tb4b4b4) Tff7b72-Tff7b72> Te6edf3short_name
Te6edf3long_nameTb4b4b4.Te6edf3isNotBlankTb4b4b4(Tb4b4b4) Tff7b72-Tff7b72> Te6edf3long_name
Tff7b72else Tff7b72-Tff7b72> Te6edf3id
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.05s